package com.uniapp.uniappboot.api;

import com.uniapp.uniappboot.domain.Quanzi;
import com.uniapp.uniappboot.service.QuanziService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RequestMapping("/quanzi")
@RestController
public class QuanziApi {

    @Autowired
    private QuanziService quanziService;
    @RequestMapping("/list")
    public List<Quanzi> list() {
        return quanziService.list();
    }

    @PostMapping("/add")
    public void add(@RequestBody Quanzi quanzi) {
        quanzi.setCreateTime(new Date());
        quanzi.setUpdateTime(new Date());
        quanziService.save(quanzi);
    }
}
